package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class JDBCDemo7 {
    public static void main(String[] args) {
        try (Connection conn = DBUtil.getConnection();) {
            String sql="SELECT id,name,password,address  " +
                    "  FROM  user  " +
                    "  WHERE  name=? AND password=?";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            pstmt.setString(1,"aa");
            pstmt.setString(2,"123456");
            ResultSet rs = pstmt.executeQuery();
            if (rs.next()) {
                System.out.println("登录成功");
            }else {
                System.out.println("登录失败");
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
